<template>
  <div class="DiyAI">
    <span class="text">AI花束生成</span>
    <span>让AI为您设计专属花束</span>
    <div class="input">
      <textarea
        placeholder="描述您想要的花束..."
        class="inputText"
        v-model="Text"
      ></textarea>
      <div class="tryText">
        <div class="trySapn">
          <span class="try" @click="trySpan">{{ tryText[num] }} →</span>
          <span class="try" @click="diyCreate">自由创作 →</span>
        </div>
        <div class="sending" @click="sending">
          <span>↑</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "DiyAI",
  data() {
    return {
      tryText: [
        "给我一捧在情人节送给女朋友的花",
        "教师节我想送给老师一束花",
        "送给我的小可爱一个花束",
        "劳动节送给老板一束花"
      ],
      Text: "",
      num: Math.floor(Math.random() * 4)
    };
  },
  methods: {
    trySpan() {
      this.Text = this.tryText[this.num];
    },
    diyCreate() {
      this.$router.push({
        path: "/diy/diy-create",
      });

      this.$store.commit("changeActNum", 1);
    },
    sending() {
      if (this.Text) {
        this.$router.push({
          path: "/diy/diy-ai-speak",
          query: { Text: this.Text },
        });
      } else {
        alert("请输入内容");
      }
    },
  },
};
</script>

<style scoped>
.DiyAI {
  height: 100vh;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  gap: 15px;
  /* 添加统一的高级主题背景 */
  background: linear-gradient(135deg, #d693a1 0%, #f8e1e7 50%, #e2f5ff 100%);
  /* 添加细微的纹理效果 */
  background-attachment: fixed;
  position: relative;
}

/* 添加背景装饰效果 */
.DiyAI::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(231, 84, 128, 0.05) 0%, transparent 50%);
  pointer-events: none;
}

.text {
  font-size: 30px;
  font-weight: 900;
  position: relative;
  z-index: 1;
}

.DiyAI span {
  color: #e75480;
  position: relative;
  z-index: 1;
}

.input {
  width: 900px;
  height: 180px;
  border-radius: 15px;
  border: 2px solid rgba(224, 224, 224, 0.8);
  display: flex;
  justify-content: space-around;
  margin-bottom: 150px;
  align-items: center;
  flex-direction: column;
  /* 增强输入框背景 */
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.1),
    0 2px 8px rgba(231, 84, 128, 0.1);
  position: relative;
  z-index: 1;
  transition: all 0.3s ease;
}

.input:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.15),
    0 4px 12px rgba(231, 84, 128, 0.15);
}

.inputText {
  /*清除textarea样式*/
  border: none;
  outline: none;
  resize: none;
  width: 96%;
  height: 60%;
  font-size: 16px;
  margin-top: 15px;
  background-color: transparent;
  color: #333;
}

.inputText::placeholder {
  color: #999;
}

.tryText {
  width: 96%;
  padding-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tryText .trySapn {
  display: flex;
  gap: 10px;
}

.tryText .try {
  font-size: 16px;
  padding: 10px;
  background: linear-gradient(135deg, #f7eef1, #fdf4f6);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid rgba(231, 84, 128, 0.2);
}

.tryText .try:hover {
  background: linear-gradient(135deg, #f8e1e7, #fce8ec);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(231, 84, 128, 0.2);
}

.sending {
  height: 40px;
  width: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e75480, #f06292);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(231, 84, 128, 0.3);
}

.sending:hover {
  background: linear-gradient(135deg, #d64d7b, #e91e63);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 16px rgba(231, 84, 128, 0.4);
}

.sending span {
  font-size: 20px;
  color: white;
  font-weight: bold;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .input {
    width: 90%;
    max-width: 500px;
  }
  
  .text {
    font-size: 24px;
  }
  
  .tryText .trySapn {
    flex-direction: column;
    gap: 8px;
  }
  
  .tryText .try {
    font-size: 14px;
    padding: 8px;
  }
}

@media (max-width: 480px) {
  .input {
    width: 95%;
    height: 160px;
  }
  
  .text {
    font-size: 20px;
  }
  
  .DiyAI span:not(.text) {
    font-size: 14px;
  }
}
</style>